#include<iostream>
#include<cstdlib>
#include<unistd.h>
#include<string>
using namespace std;
void CutString(const std::string&line,string &out1,string&out2,string step)
{
    size_t pos = line.find(step);
    if(pos != string::npos)
    {
        out1 = line.substr(0,pos);
        out2 = line.substr(pos+step.size());
    }
}
int main()
{
    cerr<<"ni hao"<<endl;
    string method = getenv("METHOD");
    string query_string;
    cerr<<method<<endl;
    if(method == "GET")
    {
        query_string = getenv("QUERY_STRING");
        cerr<<getenv("QUERY_STRING")<<endl;
    }
    if(method == "POST")
    {
        int length = atoi(getenv("Content-Length"));
        char ch;
        while(length--)
        {
            read(0,&ch,1);
            query_string+=ch;
        }
        cerr<<query_string<<endl;
        cerr<<getenv("Content-Lenght")<<endl;
    }
    //将处理完的数据返回个服务器；
    string out1,out2;
    CutString(query_string,out1,out2,"&");
   cerr<<out1<<endl;
   cerr<<out2<<endl;
   cout<<out1<<endl;
   cout<<out2<<endl;
    return 0;
}